package com.example.myapplication10;

import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import java.util.ArrayList;
import java.util.List;

public class TestsActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_tests);

        ListView listViewTests = findViewById(R.id.listViewTests);
        List<String> testList = new ArrayList<>();
        testList.add("抑郁自评量表 (SDS)");
        testList.add("焦虑自评量表 (SAS)");
        testList.add("压力测试");
        testList.add("情绪状态测试");
        testList.add("人际关系测试");

        ArrayAdapter<String> adapter = new ArrayAdapter<>(
                this,
                android.R.layout.simple_list_item_1,
                testList
        );

        listViewTests.setAdapter(adapter);

        listViewTests.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                String selectedTest = testList.get(position);
                Intent intent = new Intent(TestsActivity.this, TestDetailActivity.class);
                intent.putExtra("testName", selectedTest);
                startActivity(intent);
            }
        });
    }
}